/*
 * IBP - Technology architecture for real-time transaction
 * author	: calvin
 * email	: calvinwilliams@163.com
 *
 * Licensed under the LGPL v2.1, see the file LICENSE in base directory.
 */

#include "ibtm_api.h"
#include "ibtm_in.h"

#include "rbtree_tpl.h"

extern void FreeeStructBlock( void *pv );

LINK_RBTREENODE_STRING( LinkStructBlockTreeNode , struct TransEnv , structs_rbtree , struct StructBlock , name_rbnode , name )
QUERY_RBTREENODE_STRING( QueryStructBlockTreeNode , struct TransEnv , structs_rbtree , struct StructBlock , name_rbnode , name )
UNLINK_RBTREENODE( UnlinkStructBlockTreeNode , struct TransEnv , structs_rbtree , struct StructBlock , name_rbnode )
DESTROY_RBTREE( DestroyStructBlockTree , struct TransEnv , structs_rbtree , struct StructBlock , name_rbnode , & FreeeStructBlock )

static funcFreeRbTreeNodeEntry _DSFreeField ;
static void _DSFreeField( void *pv )
{
	struct DynamicStructField		*p_node = (struct DynamicStructField *) pv ;
	
	if( p_node )
	{
		if( p_node->field_name )
			free( p_node->field_name );
		if( p_node->field_type )
			free( p_node->field_type );
		if( p_node->field_value )
			free( p_node->field_value );
		
		free( p_node );
	}
	
	return;
}

LINK_RBTREENODE_STRING( LinkDynamicStructFieldTreeNode , struct DynamicStruct , fields_rbtree , struct DynamicStructField , field_rbnode , field_name )
QUERY_RBTREENODE_STRING( QueryDynamicStructFieldTreeNode , struct DynamicStruct , fields_rbtree , struct DynamicStructField , field_rbnode , field_name )
UNLINK_RBTREENODE( UnlinkDynamicStructFieldTreeNodeNode , struct DynamicStruct , fields_rbtree , struct DynamicStructField , field_rbnode )
DESTROY_RBTREE( DestroyDynamicStructFieldTree , struct DynamicStruct , fields_rbtree , struct DynamicStructField , field_rbnode , & _DSFreeField )

